<template>
    <div class="section">
        <!-- 内容部分 -->
        <h3>{{newsinfo.title}}</h3>
        <div class="dirtitle">
            <span>发布时间：{{newsinfo.add_time | datemsg}}</span>
            <span>点击次数：{{newsinfo.click}}</span>
        </div>
        <div class="content" v-html="newsinfo.content"></div>
        <!-- 评论子组件 绑定传值 -->
        <comment :sonmsg="id"></comment>
    </div>
</template>

<script>
// 错误提示
import { Toast } from 'mint-ui';
// 评论子组件
import comment from '../subcomponents/comment.vue';

export default {
    data() {
        return {
            id: this.$route.params.id,
            newsinfo: {}
        }
    },
    methods: {
        getnewsinfo(){
            this.$http.get('api/getnew/' + this.id).then(result => {
                if(result.body.status == 0){
                    // console.log(result.body.message[0]);
                    this.newsinfo = result.body.message[0];
                }else{
                    Toast('获取新闻详情失败')
                }
            })
        }
    },
    created() {
        this.getnewsinfo()
    },
    components: {
        'comment': comment
    }
}
</script>

<style lang="less" scoped>
    .section{
        padding: 10px;
        h3{
            font-size: 16px;
            font-weight: normal;
            text-align: center;
        }
        .dirtitle{
            color: #666;
            font-size: 13px;
            margin-top: 10px;
            display: flex;
            justify-content: space-around;
        }
        .content{
            margin-top: 10px;
        }
    }
</style>